﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using CI.Interfaces;

namespace CI.Organism
{
    /// <summary>One of the simple organisms in the hosting environment we are going to use</summary>
    [DataContract]
    public class Amoeba : Cell, IPhysical
    {
        /// <summary>
        /// One of the simple organisms in the hosting environment we are going to use
        /// </summary>
        public Amoeba(IOrganism organism, Guid guid)
            : base(organism, guid)
        { }

        /// <summary>
        /// Take this parent cell and create a new cell to be put in the new child Organism
        /// Mutate the current cell and return a new one, deep class level mutation
        /// </summary>
        /// <param name="mutationRate">mutation rate to be applied</param>
        /// <param name="childOrganism">child child Organism it will be going into</param>
        /// <returns>new cell for child</returns>
        public override ICell Mutate(double mutationRate, IOrganism childOrganism)
        {
            // create a new cell, the new function will also add 
            return new Amoeba(childOrganism, Guid) {Guid = Guid};
        }

        /// <summary>
        /// To String override
        /// </summary>
        /// <returns></returns>
        public override string ToString(string value)
        {
            return ToString();
        }

        /// <summary>
        /// basic tostring
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return "Amoeba";
        }

        /// <summary>IO manifest, used by neural network when mutating</summary>
        public ReadOnlyCollection<SynapseIO> IOManifest
        {
            // Return a wrapped copy of the results.
            get { return new ReadOnlyCollection<SynapseIO>(_ioManifest); }
        }

        [DataMember]
        private SynchronizedCollection<SynapseIO> _ioManifest = new SynchronizedCollection<SynapseIO>();

        /// <summary>
        /// Get the synapseIO with the corresponding binding name
        /// </summary>
        /// <param name="bindingName"></param>
        /// <returns></returns>
        public SynapseIO GetSynapseIO(string bindingName)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Get the synapseIO with the corresponding Guid
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public SynapseIO GetSynapseIO(Guid guid)
        {
            throw new NotImplementedException();
        }
    }
}